<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>

    var arr = [99, 88, 66, 77];
    var obj = { name: '张茂森', age: 22, sex: '男' }

    for (let i in arr) {//for in 来循环数组 i 则是数组中每一项对应的下标
        console.log(i);   //0,1,2,3
    }
    for (let i of arr) {//for of 来循环数组 i 则是数组中的每一项
        console.log(i);   //99,88,66,77
    }


    for (let i in obj) {//for in 来循环对象 i 则是对象的每一个键
        console.log(i);   //name age sex
    }
    for (let i of obj) {//for of 来循环对象 则会报错obj is not iterable（obj不是一个可迭代的）
        console.log(i);   
    }

    
</script>